﻿using System.Collections.Generic;
using System.Runtime.Serialization;

public enum ActivityType
{
    new_member, 
    chapter_greeting, 
    photo_upload, 
    new_discussion, 
    new_reply, 
    new_rsvp, 
    edit_rsvp, 
    photo_tag, 
    photo_comment, 
    new_checkin
}

[DataContract]
public partial class Activities
{
    [DataMember(Name = "results")]
    public List<Activity> Items { get; set; }
    [DataMember]
    public object meta { get; set; }
}

public partial class Activity 
{
    public string rsvp_comment {get; set;}
    public string group_id {get; set;}
    public string event_id {get; set;}
    public string updated {get; set;}
    public ActivityType item_type {get; set;}
    public string member_id {get; set;}
    public string event_date {get; set;}
    public string rsvp_response {get; set;}
    public string published {get; set;}
    public string member_name {get; set;}
    public string event_name {get; set;}
    public string id {get; set;}
    public string link {get; set;}
    public string group_name {get; set;}
    public string title {get; set;}
    public string event_url {get; set;}
    public string photo_url {get; set;}
    public string bio {get; set;}
    public string photo_id {get; set;}
    public string photo_album_id {get; set;}
    public string comment {get; set;}
    public string album_name {get; set;}
    public string discussion_title { get; set; }
    public string discussion_body { get; set; }


    public string FriendlyComment
    {
        get
        {
            string message = "";
            switch (item_type)
            {
                case ActivityType.new_rsvp:
                case ActivityType.edit_rsvp:
                    message = rsvp_comment;
                    break;

                case ActivityType.photo_comment:
                    message = comment;
                    break;

                case ActivityType.new_member:
                    message = bio;
                    break;

                case ActivityType.new_discussion:
                    message = discussion_title + "\n" + discussion_body;
                    break;
            }
            return (message.Length > 200 ? message.Substring(0, 197) + "..." : message);
        }
    }

    public string FriendlyMessage
    {
        get
        {
            string message;
            switch (item_type)
            {
                case ActivityType.new_rsvp:
                case ActivityType.edit_rsvp:
                    message = string.Format("{0} is {1} the event: {2}", member_name, "attending", event_name);
                    break;

                case ActivityType.new_member:
                    message = string.Format("{0} joined the group.", member_name);
                    break;

                case ActivityType.photo_comment:
                    message = string.Format("{0} commented on a photo in the album {1}", member_name, album_name);
                    break;

                case ActivityType.photo_upload:
                    message = string.Format("{0} uploaded new photos to the album {1}", member_name, album_name);
                    break;

                case ActivityType.photo_tag:
                    message = string.Format("{0} tagged a photo in the album {1}", member_name, album_name);
                    break;

                case ActivityType.new_discussion:
                    message = string.Format("{0} started a new discussion.", member_name);
                    break;
              
                default:
                    message = item_type.ToString();
                    break;

            }
            return message + "\nin " + group_name;
        }
    }
}
